/**
 *
 */
package com.neiquan.secondhand.controller;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.neiquan.secondhand.po.Goods;
import com.neiquan.secondhand.service.CommonService;
import com.neiquan.secondhand.service.GoodService;

/**
 *	公共Controller
 * @author chenjunnan
 * @date 2016-6-12 下午01:33:05
 * @descript 公共Controller
 */
@Controller
@RequestMapping("/api/common/")
public class CommonController{
	@Autowired
	private CommonService commonService;
	
	/**
	 * 获取省市区 
	 * @return
	 * @throws IOException 
     */
	@SuppressWarnings("all")
	@RequestMapping(value="getAddress.do", method= RequestMethod.POST)
	public String getAddress(String id,HttpServletResponse response) throws IOException {
		response.setContentType("text/html;charset=UTF-8"); 
	    
		List<Map> list=commonService.getAddress(id);
		 JSONArray json = new JSONArray();
         for(Map a : list){
             JSONObject jo = new JSONObject();
             jo.put("dictionaries_id", a.get("dictionaries_id"));
             jo.put("name", a.get("name"));
             jo.put("BIANMA", a.get("BIANMA"));
             json.add(jo);
         }
         response.getWriter().print(json.toString()); 
        return null;
	}
}

